import { ARCGIS } from "./arcgis";

export var SEARCH_LAYER = [
    { id: '1', label: '道路', name: 'dl', url: [ARCGIS.queryUrl + '/9'] },
    { id: '2', label: '桥梁', name: 'ql', url: [ARCGIS.queryUrl + '/15'] },
    { id: '3', label: '小区', name: 'xq', url: [ARCGIS.queryUrl + '/14'] },
    { id: '4', label: '泵站', name: 'bz', url: [ARCGIS.queryUrl + '/4'] },
    {
        id: '6-1',
        label: '检查井',
        name: 'jcj',
        url: [
            ARCGIS.queryUrl + '/5',
            ARCGIS.queryUrl + '/6',
            ARCGIS.queryUrl + '/7',
            ARCGIS.queryUrl + '/8',
        ],
    },
    { id: '6-2', label: '污水管', name: 'wsg', url: [ARCGIS.queryUrl + '/12'] },
    { id: '6-3', label: '雨水管', name: 'ysg', url: [ARCGIS.queryUrl + '/10'] },
    { id: '6-4', label: '合水管', name: 'hsg', url: [ARCGIS.queryUrl + '/11'] },
    { id: '6-5', label: '截污管', name: 'jwg', url: [ARCGIS.queryUrl + '/13'] },
]

// * 搜索tab中新增
export var addSearch = function(node, layers) {
    if (node.id === '1') {
        layers.push({
            id: '1',
            label: '道路',
            name: 'dl',
            url: [ARCGIS.queryUrl + '/9'],
        })
    } else if (node.id === '2') {
        layers.push({
            id: '2',
            label: '桥梁',
            name: 'ql',
            url: [ARCGIS.queryUrl + '/15'],
        })
    } else if (node.id === '3') {
        layers.push({
            id: '3',
            label: '小区',
            name: 'xq',
            url: [ARCGIS.queryUrl + '/14'],
        })
    } else if (node.id === '4') {
        layers.push({
            id: '4',
            label: '泵站',
            name: 'bz',
            url: [ARCGIS.queryUrl + '/4'],
        })
    } else if (node.id === '6-1') {
        layers.push({
            id: '6-1',
            label: '检查井',
            name: 'jcj',
            url: [
                ARCGIS.queryUrl + '/5',
                ARCGIS.queryUrl + '/6',
                ARCGIS.queryUrl + '/7',
                ARCGIS.queryUrl + '/8',
            ],
        })
    } else if (node.id === '6-2') {
        layers.push({
            id: '6-2',
            label: '污水管',
            name: 'wsg',
            url: [ARCGIS.queryUrl + '/12'],
        })
    } else if (node.id === '6-3') {
        layers.push({
            id: '6-3',
            label: '雨水管',
            name: 'ysg',
            url: [ARCGIS.queryUrl + '/10'],
        })
    } else if (node.id === '6-4') {
        layers.push({
            id: '6-4',
            label: '合水管',
            name: 'hsg',
            url: [ARCGIS.queryUrl + '/11'],
        })
    } else if (node.id === '6-5') {
        layers.push({
            id: '6-5',
            label: '截污管',
            name: 'jwg',
            url: [ARCGIS.queryUrl + '/13'],
        })
    }
    return layers;
}

// * 搜索tab中移除
export var removeSearch = function(node, layers) {
    let label = ''
    let name = ''
    if (node.id === '1') {
        label = '道路'
        name = 'dl'
    } else if (node.id === '2') {
        label = '桥梁'
        name = 'ql'
    } else if (node.id === '3') {
        label = '小区'
        name = 'xq'
    } else if (node.id === '4') {
        label = '泵站'
        name = 'bz'
    } else if (node.id === '6-1') {
        label = '检查井'
        name = 'jcj'
    } else if (node.id === '6-2') {
        label = '污水管'
        name = 'wsg'
    } else if (node.id === '6-3') {
        label = '雨水管'
        name = 'ysg'
    } else if (node.id === '6-4') {
        label = '合水管'
        name = 'hsg'
    } else if (node.id === '6-5') {
        label = '截污管'
        name = 'jwg'
    }
    for (let i = 0; i < layers.length; i++) {
        if (layers[i].label === label && layers[i].name === name) {
            layers.splice(i, 1)
            break
        }
    }
    return layers;
}